<?xml version="1.0" encoding="utf-8"?>
<Content type="xform" name="EditContent">
	<model>
		<instance>
			<Query name="OrderDownloads" storedProcedure="spOrderDownload" logActivity="true" output="csv" filePrefix="" fileUID="log">
				<param name="dStartDate" type="datetime"  value=""/>
				<param name="dEndDate" type="datetime"  value=""/>
				<param name="cOrderType" type="string"  value="Order"/>
				<param name="nOrderStage" type="number"  value="6"/>
				<param name="lastDownloadID" type="number"  value=""/>
			</Query>

		</instance>
		<submission id="OrderDownloadSubmission" action="/ewcommon/tools/export.ashx?ewcmd=Reports&amp;ewCmd2=Order-Downloads&amp;reportXsl=Order-Downloads" method="post" event="return form_check(this)"/>
		<bind nodeset="Query">
			<bind id="cartStage" nodeset="param[@name='nOrderStage']/@value" required="false()" type="string"/>
			<bind id="cOrderType" nodeset="param[@name='cOrderType']/@value" required="false()" type="string"/>
			<bind id="dateStart" nodeset="param[@name='dStartDate']/@value" required="false()" type="string"/>
			<bind id="dateEnd" nodeset="param[@name='dEndDate']/@value" required="false()" type="string"/>
			<bind id="lastDownloadId" nodeset="param[@name='lastDownloadID']/@value" required="false()" type="string"/>
			<bind id="format" nodeset="@output" required="true()" type="string"/>
		</bind>

	</model>
	<group ref="OrderDownload" class="2col">
		<label>Order Download</label>
			<group>
				<select1 bind="cartStage"  class="ewQuery" query="CartStatus">
					<label>Cart Stage</label>
					<value/>
				</select1>

				<select1 bind="cOrderType" appearance="minimal">
					<label>Cart Type</label>
					<item>
						<label>Order</label>
						<value>Order</value>
					</item>
					<item>
						<label>Quote</label>
						<value>Quote</value>
					</item>
					<value/>
				</select1>

				<select1 bind="format" appearance="minimal" class="required">
					<label>Output Format</label>
					<item>
						<label>CSV</label>
						<value>csv</value>
					</item>
					<item>
						<label>Excel</label>
						<value>xls</value>
					</item>
					<item>
						<label>Raw XML</label>
						<value>rawxml</value>
					</item>
					<value/>
				</select1>
			</group>
			<group >
				<select1 bind="DateFilter" appearance="full">
					<label>Select orders for download</label>
					<item>
						<label>By specific date</label>
						<value>ByDate</value>
						<toggle case="DateFilter_0" event="DOMActivate"/>
					</item>
					<item>
						<label>By date last download</label>
						<value>ByDownloadLog</value>
						<toggle case="DateFilter_1" event="DOMActivate"/>
					</item>
				</select1>
				<switch >
					<case id="DateFilter_0">
						<input bind="dBegin" class="calendarTime">
							<label>From</label>
							<value></value>
						</input>
						<input bind="dEnd" class="calendarTime">
							<label>To</label>
							<value></value>
						</input>
					</case>
					<case id="DateFilter_1">
						<select1 bind="lastDownloadId" class="ewQuery" query="execute spGenericReportLastDownloadedDropDown 'spOrderDownload'">
							<label>Order since last download on:</label>
						</select1>
					</case>
				</switch>
			</group>
	</group>
	<group ref="SubmitDownload" class="inline">
		<submit submission="" ref="ewSubmitOrderDownload" class="principle">
			<label>Download Orders</label>
		</submit>
	</group>
</Content>
